var Unify={
	jsData:{},
	clickNum:0,
	clickTime:0,
	loadJs:function(url,callback){
		if(Unify.jsData[url]){
			callback&&callback();
			return;
		}
		Unify.jsData[url]=true;
		var script=document.createElement('script');
		script.type="text/javascript";
		if(typeof(callback)!="undefined"){
			if(script.readyState){
				script.onreadystatechange=function(){
					if(script.readyState == "loaded" || script.readyState == "complete"){
						script.onreadystatechange=null;
						callback&&callback();
					}
				}
			}else{
				script.onload=function(){
					callback&&callback();
				}
			}
		}
		script.src=url;
		document.head.appendChild(script);
	},
	loadJsByUrls(urls,callback){
		let total=urls.length;
		let i=0
		function load(i){
			Unify.loadJs(urls[i],()=>{
				i++;
				if(i===total){
					callback&&callback();
				}else{
					load(i);
				}
			})
		}
		load(i);
	},
	filesadded:'', //保存已经绑定文件名字的数组变量
	loadjscssfile:function(filename, filetype) {//动态加载文件         
		if (filetype == "js") { //判断文件类型
			var fileref = document.createElement('script'); //创建标签
			fileref.setAttribute("type", "text/javascript"); //定义属性type的值为text/javascript
			fileref.setAttribute("src", filename); //文件的地址
		}
		else if (filetype == "css") { //判断文件类型
			var fileref = document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("href", filename);
		}
		if (typeof fileref != "undefined"){
			document.head.appendChild(fileref);
		}
	},
	checkloadjscssfile:function(filename, filetype) {//防止重复加载   
		if (filesadded.indexOf("[" + filename + "]") == -1) {// indexOf判断数组里是否有某一项
			loadjscssfile(filename, filetype);
			filesadded += "[" + filename + "]"; //把文件名字添加到filesadded
		}
		else {
			alert("文件重复加载");
		}
	},
	/**排版*/
	displayRank(array,xNum=1,xDis=0,yDis=0,x=0,y=0,sign=1)
	{
		for(let i=0;i<array.length;i++){
			let display=array[i];
			display.x=x+parseInt(i%xNum)*(display.width+xDis)*sign;
			display.y=y+parseInt(i/xNum)*(display.height+yDis)*sign;
		}
	},
	color16ToHtml(c){
		if(c=='random') c=parseInt(Math.random()*0XFFFFFF);
		return "#"+c.toString(16);
	},
	rbgToHtml(r=0,b=0,g=0){
		var arr=[r.toString(16),b.toString(16),g.toString(16)];
		var color='#';
		for(var i=0;i<arr.length;i++)color+=arr[i]=='0'?arr[i]+0:arr[i];
		return color
	},
	set16ToRgb(str){
	   var reg = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/
	   if(!reg.test(str)){return;}
	   let newStr = (str.toLowerCase()).replace(/\#/g,'')
	   let len = newStr.length;
	   if(len == 3){
		   let t = ''
		   for(var i=0;i<len;i++){
			   t += newStr.slice(i,i+1).concat(newStr.slice(i,i+1))
		   }
		   newStr = t
	   }
	   let arr = []; //将字符串分隔，两个两个的分隔
	   for(var i =0;i<6;i=i+2){
		   let s = newStr.slice(i,i+2)
		   arr.push(parseInt("0x" + s))
	   }
	   return 'rgb(' + arr.join(",")  + ')';
	},
	setRgbTo16(str){
		let reg = /^(rgb|RGB)/;
		if(!reg.test(str)){return;}
		var arr = str.slice(4, str.length-1).split(",")
		let color = '#';
		for(var i=0;i<arr.length;i++){
			 var t = Number(arr[i]).toString(16)
			 if(t == "0"){   //如果为“0”的话，需要补0操作,否则只有5位数
				 t =  t + "0"
			 }
			 color += t;
		}
		return color;
	},
	setLocalData(key,value){//本地数据-保存(value必须为string)
		localStorage.setItem(key,value);
	},
	getLocalData(key){//本地数据-读取(数据为string)
		return localStorage.getItem(key);
	},
	removeLocalData(key){//本地数据-删除
		localStorage.removeItem(key);
	},
	/**本地数据存储,type("set","get","remove"),name(key值名字),data(数据，所有存储数据必须是字符串) 
	 * JSON.stringify(object); //将json格式转换成string
	 * JSON.parse(string); //将string转换成json
	*/
	localStorage(type,name,data){
		name='s'+name;
		if(type=="set"){
			localStorage.setItem(name,data);
		}else if(type=="get"){
			return localStorage.getItem(name);
		}else if(type=="remove"){
			localStorage.removeItem(name);
		}
	},
	arrayRandomSort(arr){//数组随机排序
		arr.sort(()=>{return 0.5-Math.random()});
	},
	/**删除数组中相同的值*/
	arrayRemoveSame(array){
		return [...new Set(array)];
	},
	/**得到数组里的随机值*/
	getArrayRandomValue(array,num=1){
		if(num==1){
			return array[Math.floor(Math.random()*array.length)];
		}else{
			let arr=[];
			num=num<array.length?num:array.length;
			while(arr.length<num){
				let n=array[Math.floor(Math.random()*array.length)];
				if(!arr.includes(n))arr.push(n);
			}
			return arr;
		}
	},
	/**得到日期格式使用dateFormat('YY/MM/DD hh:mm:ss 星期d',new Date) 如果数字<10时前面不想要0可以只用一个字母，如h:mm*/
	dateFormat(fmt, date) {
      let ret;
	  let ws=['日','一','二','三','四','五','六']
      const opt = {
        "Y+": date.getFullYear().toString(),        // 年
		"M+": (date.getMonth() + 1).toString(),     // 月
		"D+": date.getDate().toString(),            // 日
		"h+": date.getHours().toString(),           // 时
		"m+": date.getMinutes().toString(),         // 分
		"s+": date.getSeconds().toString(),         // 秒
		"d+": ws[date.getDay()]         		// 周(星期)
      };
      for (let k in opt) {
          ret = new RegExp("(" + k + ")").exec(fmt);
          if (ret) {
              fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
          };
      };
      return fmt;
    },
	/**深度克隆*/
	deepClone(obj) {
		try{      	return JSON.parse(JSON.stringify(obj)); }
		catch(e){	console.error('不是对象不可以克隆')		  }
		return obj;
	},
	//string转为xml
	stringToXml(str){
		var parser=new DOMParser();
		var xmlDoc=parser.parseFromString(str,"text/xml");
		return xmlDoc;
	},
	//xml转为json
	xmlToJson(xml){
		// Create the return object
		var obj = {};
		if (xml.nodeType == 1) { // element
			// do attributes
			if (xml.attributes.length > 0) {
				obj["@attributes"] = {};
				for (var j = 0; j < xml.attributes.length; j++) {
					var attribute = xml.attributes.item(j);
					obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
				}
			}
		} else if (xml.nodeType == 3) { // text
			obj = xml.nodeValue;
		}
		// do children
		if (xml.hasChildNodes()) {
			for(var i = 0; i < xml.childNodes.length; i++) {
				var item = xml.childNodes.item(i);
				var nodeName = item.nodeName;
				if (typeof(obj[nodeName]) == "undefined") {
					obj[nodeName] = Unify.xmlToJson(item);
				} else {
					if (typeof(obj[nodeName].length) == "undefined") {
						var old = obj[nodeName];
						obj[nodeName] = [];
						obj[nodeName].push(old);
					}
					if(!Array.isArray(obj[nodeName]))obj[nodeName]=[];
					obj[nodeName].push(Unify.xmlToJson(item));
				}
			}
		}
		return obj;
	},
	/**对象转数组*/
	objectToArray(obj) {
		//Object.values(obj)
		let result = [];
		for (let key in obj) {
		  result.push(obj[key])
		}
		return result
	},
	/**复制字符串*/
	copyString(str) {
		// 创建input元素
		const el = document.createElement('input')
		// 给input元素赋值需要复制的文本
		el.setAttribute('value', str)
		// 将input元素插入页面
		document.body.appendChild(el)
		// 选中input元素的文本
		el.select();
		// 复制内容到剪贴板
		document.execCommand('copy');
		// 删除input元素
		document.body.removeChild(el);
		alert('复制成功');
	},
	/**汉字转unicode*/
	toUnicode(data){
		var str =''; 
		for(var i=0;i<data.length;i++){
			str+="\\u"+data.charCodeAt(i).toString(16);
		}
		return str;
	},
	/**unicode转汉字*/
	toChineseWords(data){
		data = data.split("\\u");
		var str ='';
		for(var i=0;i<data.length;i++){
			str+=String.fromCharCode(parseInt(data[i],16).toString(10));
		}
		return str.substr(1);//不知道为什么首位是个空格，所以要把空格去掉
	},
	/**摩斯转换，type=0是转为摩斯码，type=1是转为字母数字等*/
	mosi(str,type=0){
		//创建字符数组
		var oldarr = [
			'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
			'1','2','3','4','5','6','7','8','9','0',
			'.',':',',',';','?','=',"'",'/','!','-','_','"','(',')','$','&','@','+',' '
		]
		//创建对应的摩斯码数组
		var newarr = [
			'.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..',
			'.----','..---','...--','....-','.....','-....','--...','---..','----.','-----',
			'.-.-.-','---...','--..--','-.-.-.','..--..','-...-','.----.','-..-.','-.-.--','-....-','..--.-','.-..-.','-.--.','-.--.-','...-..-','.-...','.--.-.','.-.-.',' '
		]
		//将小写字母全部转化为大写字母处理
		var str=str.toUpperCase();
		var size;
		var value="";
		if(type==1){//使用空格做为分隔符
			str=str.split(" ");
		}
		for(i=0;i<str.length;i++){
			if(type==0){
				size=oldarr.indexOf(str.charAt(i));
				value += newarr[size] + " ";
			}else{
				size=newarr.indexOf(str[i]);
				value += oldarr[size]||str[i];
			}
		}
		return value;
	},
	/**摩斯和汉字转换，type为0时汉字转摩斯码，type为1时摩斯码转汉字*/
	mosiUnicode(str,type=0){
		var value='';
		if(type==0){
			str = str.split("\\u");
			str.forEach(a=>value+=Unify.mosi(a,type));
		}else{
			var s='';
			for(let i=0;i<str.length;i++){
				s+=((i%4==0?'\\u':'')+str[i]);
			}
			value=Unify.toChineseWords(s);
		}
		return value;
	},
	/**文本转Base64,type为0时加密为1时解密 */
	base64(str,type=0){
		let value='';
		if(type==0){
			value=window.btoa(unescape(encodeURIComponent(str)));
		}else{
			try{
				value=decodeURIComponent(escape(window.atob(str)));
			}catch(e){
				value='注意：密文有错误'
				alert(value);
			}
		} 		
		return value;
	},
	/**单击或是双击的判断，默认是0.3秒内点两次为双击否则为单击 */
	clickOrDouble(click,double,gap=300){
		Unify.clickNum++;
		clearTimeout(Unify.clickTime);
		Unify.clickTime=setTimeout(()=>{
			if(Unify.clickNum>0){
				Unify.clickNum=0;
				click&&click();
			}
		},gap)//gap毫秒内没有接受到第二下表示单击 
		if(Unify.clickNum>=2){//双击
			clearTimeout(Unify.clickTime);
			Unify.clickNum=0;
			double&&double();
		}
	},
	/**键盘事情 */
	keyboardEvent(onKeyDown,onKeyUp){
		window.addEventListener('keydown', onKeyDown,true);
		window.addEventListener('keyup', onKeyUp,true);
	},
	/**2次方的升降序*/
	mathUpDown(num,type=1){
		if(type==1) return Math.pow(2,num);//2次方升序
		else        return Math.log2(num);//2次方降序
	},
	/**加密 通过32位方法
	* 使用8个字节,1个字节8位,第1个字节为id(共8位),第2和3字节为数量(共16位),第4到7字节为UID(共32位),第8个字节为随机数(共16位)*/
	encrytBy32(id,count,uid){
		//console.log(id,count,uid)
		var value;
		var random=Math.floor(Math.random()*10);
		var byteArr = new ArrayBuffer(8);
		var dv = new DataView(byteArr);
		dv.setUint8(0, id);  //1 
		dv.setUint8(1, count);//2
		dv.setUint32(3, uid,true);//4//使用 littleEndian 字节顺序（最低有效字节位于最前）的流将写入
		dv.setUint8(7, random);//1
		var s1=dv.getUint32(0,true);
		var s2=dv.getUint32(4,true);
		//console.log(s1,s2)
		s1=s1.toString('32');
		s2=s2.toString('32');
		//console.log(s1,s2)
		value=s1+"Z"+s2;
		value=value.toLocaleUpperCase();//激活码全转成大写
		value=value.replace(/0/g,"X");//所有0转为X
		value=value.replace(/O/g,"Y");//所有O转为Y
		//console.log(value)
		return value;
	},
	/**解密 通过32位方法*/
	decryptBy32(key){
		var value;
		key=key.replace(/X/g,"0");//所有X转为0
		key=key.replace(/Y/g,"O");//所有Y转为O
		var arr=key.split("Z");
		var byteArr = new ArrayBuffer(8);
		var dv = new DataView(byteArr);
		var code=parseInt(arr[0],32);
		//console.log(code);
		dv.setUint32(0,code,true);
		code=parseInt(arr[1],32);
		//console.log(code);
		dv.setUint32(4,code,true);
		value=("id="+dv.getUint8(0)+",count="+dv.getUint8(1)+",uid="+dv.getUint32(3,true)+",random="+dv.getUint8(7));
		return value;
	},
	/**随机修改位置*/
	randomChangePosition(nodes){
		var array=[];
		for (var i = 0;i < nodes.length; i++) {
			array.push([nodes[i].x,nodes[i].y]);
		}
		Unify.arrayRandomSort(array);
		for (var i = 0;i < array.length; i++) {
			[nodes[i].x,nodes[i].y]=array[i];
		}
	},
	/**数字格式转换,单个数字前面加0*/
	numberFormat(num){
		num=parseInt(num);
		if(num>=10)	return String(num);
		else		return "0"+num;
	},
	/**获取API数据*/
	getAPI(url,callBack,type='GET',param=null){
		var xhr=new XMLHttpRequest();
		xhr.open(type,url,true);
		if(type=='POST'){//POST方式要带的参数
			if(typeof(param)=='object'){//设置请求头，接口文档显示的是json
				xhr.setRequestHeader("Content-Type", "application/json");
				xhr.send(JSON.stringify(param));
			}else{//接口文档显示的是key1=value1&key2=value2方式
				xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr.send(param);
			}
			
		}else{//使用GET方式
			xhr.send();
		}
		xhr.onreadystatechange=()=>{
			//console.log(xhr.response)
			if(xhr.readyState==4&&xhr.status==200){
				callBack&&callBack(xhr.response)
			}
		}
	},
	/**中英互翻译*/
	chToEn(val,callBack){
		var result;
		var url=`https://api.oioweb.cn/api/txt/QQFanyi?sourceText=${val}`;
		Unify.getAPI(url,(str)=>{
			try{
				let data=JSON.parse(str);
				if(data.code==200){
					result=data.result.targetText
					callBack(result);
				}
			}catch(e){
				console.warn('结果有错')
			}
		});
	},
	/***拼音转换
	 * 0：xià->xia4
	 * 1：xia4->xià
	*/
	changePinyin(pinyin,type=0){
		//汉语声调标注规律顺序是aoeiuv，其中如果是i、u并排谁在后标谁头上，如果iú或uí
		var cag='āáǎàa,ōóǒòo,ēéěèe,īíǐìi,ūúǔùu,ǖǘǚǜü,ǖǘǚǜv';
		var cags=cag.split(',');
		let numi=0;
		cags.find((n)=>{
			let len=n.length-1;
			if(type==0){
				for(let i=0;i<len;i++){
					let a=n[i];
					if(pinyin.indexOf(a)>=0){
						pinyin=pinyin.replace(a,n[len]);
						pinyin+=(i+1);
						return true;
					}
				}
			}else if(type==1){
				let a=n[len];
				if(pinyin.indexOf('iu')>=0){//i、u并排靠后标
					numi=pinyin.indexOf('i');
					pinyin=pinyin.replace('i','');
				}
				let jqxs=['jü','qü','xü'];
				jqxs.forEach((a)=>{
					if(pinyin.indexOf(a)>=0){
						pinyin=pinyin.replace('ü','u');
					}
				})
				if(pinyin.indexOf(a)>=0){
					let cnt=pinyin.length-1
					let num=pinyin[cnt];
					pinyin=pinyin.replace(a,n[num-1]);
					//console.log(a,n[num-1])
					pinyin=pinyin.substr(0,cnt);
					if(numi>0){
						pinyin=pinyin.split('');
						pinyin.splice(numi,0,'i');
						pinyin=pinyin.join('');
					}
					return true;
				}
			}
		})
		return pinyin;
	},
	/***拼音转换2
	 * 2：xia->[xiā,xiá,xiǎ,xià]
	 * 如果nums有值它是个数组如[2,3],那么xia->[xiá,xiǎ]只转2和3声
	*/
	changePinyin2(pinyin,num=4,nums){
		var values=[];
		if(nums){
			for(let i=0;i<nums.length;i++){
				values.push(Unify.changePinyin(pinyin+nums[i],1))
			}
		}else{
			for(let i=1;i<=num;i++){
				values.push(Unify.changePinyin(pinyin+i,1))
			}
		}
		return values;
	},
	/**去除空格*/
	trim(ostr){
		return ostr.replace(/([ ]{1})/g,"");
	},
	/**是否移动端*/
	isMobile(type=0){
		if(type==0){//是否移动端
			return /iPhone|iPad|iPod|SymbianOS|Windows Phone|ohos|Android/i.test(navigator.userAgent);
		}else if(type==1){//是否IOS端
			return /iPhone|iPad|iPod/i.test(navigator.userAgent);
		}else if(type==2){//是否安卓端
			return /Android/i.test(navigator.userAgent);
		}else if(type==3){//是否鸿蒙端
			return /ohos/i.test(navigator.userAgent);
		}
		return false;
	},
	/**得到00:00.000格式*/
	getMillisecondTimeFormatByNum(millisecond,showNum=3,type = ":") {
		var num=parseInt(millisecond/1000);
		var minute = Unify.numberFormat((num / 60) % 60);
		var second = Unify.numberFormat(num % 60);
		var milSec = Unify.numberFormat((millisecond-num*1000)/10);
		if(showNum==3){
			milSec=parseInt(millisecond-num*1000);
			if(milSec<10)       milSec='00'+milSec;
			else if(milSec<100) milSec='0'+milSec;
		}
		return minute + type + second+ '.' + milSec;
	},
	Alert(str,time=2){
		time=time*1000;  
		var msgw,msgh,bordercolor;  
		msgw=350;//提示窗口的宽度  
		msgh=80;//提示窗口的高度  
		titleheight=25 //提示窗口标题高度  
		bordercolor="#336699";//提示窗口的边框颜色  
		titlecolor="#99CCFF";//提示窗口的标题颜色  
		var sWidth,sHeight;  
		//获取当前窗口尺寸  
		sWidth = document.body.offsetWidth;  
		sHeight = document.body.offsetHeight;  
	//    //背景div  
		var bgObj=document.createElement("div");  
		bgObj.setAttribute('id','alertbgDiv');  
		bgObj.style.position="absolute";  
		bgObj.style.top="0";  
		bgObj.style.background="#00000000";  
		bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";  
		bgObj.style.opacity="0.6";  
		bgObj.style.left="0";  
		bgObj.style.width = sWidth + "px";  
		bgObj.style.height = sHeight + "px";  
		bgObj.style.zIndex = "10000";  
		document.body.appendChild(bgObj);  
		//创建提示窗口的div  
		var msgObj = document.createElement("div")  
		msgObj.setAttribute("id","alertmsgDiv");  
		msgObj.setAttribute("align","center");  
		msgObj.style.background="white";  
		msgObj.style.border="1px solid " + bordercolor;  
		msgObj.style.position = "absolute";  
		msgObj.style.left = "50%";  
		msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";  
		//窗口距离左侧和顶端的距离   
		msgObj.style.marginLeft = "-225px";  
		//窗口被卷去的高+（屏幕可用工作区高/2）-150  
		msgObj.style.top = document.body.scrollTop+(window.screen.availHeight/2)-150 +"px";  
		msgObj.style.width = msgw + "px";  
		msgObj.style.height = msgh + "px";  
		msgObj.style.textAlign = "center";  
		msgObj.style.lineHeight ="25px";  
		msgObj.style.zIndex = "10001";  
		document.body.appendChild(msgObj);  
		//提示信息标题  
		var title=document.createElement("h4");  
		title.setAttribute("id","alertmsgTitle");  
		title.setAttribute("align","left");  
		title.style.margin="0";  
		title.style.padding="3px";  
		title.style.background = bordercolor;  
		title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";  
		title.style.opacity="0.75";  
		title.style.border="1px solid " + bordercolor;  
		title.style.height="18px";  
		title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";  
		title.style.color="white";  
		title.innerHTML="提示信息";  
		document.getElementById("alertmsgDiv").appendChild(title);  
		//提示信息  
		var txt = document.createElement("p");  
		txt.setAttribute("id","msgTxt");  
		txt.style.margin="16px 0";  
		txt.innerHTML = str;  
		document.getElementById("alertmsgDiv").appendChild(txt);  
		//设置关闭时间  
		window.setTimeout(()=>{
			document.body.removeChild(document.getElementById("alertbgDiv"));  
			document.getElementById("alertmsgDiv").removeChild(document.getElementById("alertmsgTitle"));  
			document.body.removeChild(document.getElementById("alertmsgDiv"));  
		},time);   
	},
	/**保存canvas */
	saveCanvas(canvas){
		//保存时发现错误可能是图片跨域问题，放到服务器上会变好。
		var dataURL = canvas.toDataURL('images/jpeg');
		var link = document.createElement('a');
		link.href = dataURL;
		link.download = 'image.png';
		document.body.appendChild(link);
		link.click();
		document.body.removeChild(link);
	},
	/**获取随机位数,num表示几位数*/
	getRandomWeiShu(num){
		var mix=Math.pow(10,num)-1;
		var min=Math.pow(10,num-1);
		return Math.floor(Math.random()*(mix-min+1)+min);
	},
	/**字符串传数组*/
	stringToArray(str){
		let signs=[' ','，','-','。',';','；','、'];
		signs.forEach(s=>{
			str=str.replaceAll(s,',');
		})
		return str.split(',');
	},
	getStageWH(){
		return {w:window.innerWidth,h:window.innerHeight};
	},
	/**像蛇移动*/
	snakeMove(snakes,head,maxTime=0){
		let count=head.snakeCount||0;
		let time=head.snakeTime||0;
		if(time>=maxTime){
			time=0;
			snakes[count].x=head.x;
			snakes[count].y=head.y;
			count++;
			if(count==snakes.length)count=0;
			head.snakeCount=count;
		}
		time++;
		head.snakeTime=time;
	},
	/**计算两点间的距离*/
	posToPosDistance(v1,v2){
		let x=v1.x-v2.x;
		let y=v1.y-v2.y;
		return Math.hypot(x,y);
	},
	/**获取地址上的变量
	 * 如http://ywx.com?var1=123&var2=456
	 * 获取var1时调用getUrlVar('var1');
	*/
	getUrlVar(name){
		// 首先，创建一个新的URL对象
		const url = new URL(window.location.href);
		// 然后，使用URLSearchParams来获取所有的查询参数
		const params = new URLSearchParams(url.search);
		// 获取特定的查询参数
		const value = params.get(name); // 返回 'value'
		return value;
	},
	fpsMeter(callBack){
		let prevTime = Date.now(),frames = 0;
		const memory = performance.memory;
		requestAnimationFrame(function loop(){
		  const time = Date.now();
		  frames++;
		  if (time > prevTime + 1000){
			let fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) );
			prevTime = time;
			frames = 0;
			let mem='0M';
			if(memory){
				mem=(memory.usedJSHeapSize/(1024*1024)).toFixed(2)+'M';
			}
			if(callBack){
				callBack({fps:fps,mem:mem});
			}
			//console.info('FPS: ', fps);
			//console.log('JS heap size limit:', memory.jsHeapSizeLimit); //上下文内可用堆的最大体积，以字节计算。
			//console.log('JS heap used size:', memory.usedJSHeapSize);//当前 JS 堆活跃段（segment）的体积，以字节计算。
			//console.log('JS heap total size:', memory.totalJSHeapSize);//已分配的堆体积，以字节计算。
		  }
		  requestAnimationFrame(loop);
		});
	  }
}
